home *** CD-ROM | disk | FTP | other *** search
Text File | 1987-08-01 | 5.0 KB | 261 lines | [TEXT/ttxt] |
-
- ;
- ; GetCreator.a, assembly language support for Launch
- ; ©Apple Computer, Inc. 1987
- ; All Rights Reserved.
- ;
-
-
- BLANKS ON
- STRING PASCAL
-
- PRINT OFF
- INCLUDE 'FSEqu.a'
- INCLUDE 'FSPrivate.a'
- INCLUDE 'SysEqu.a'
- INCLUDE 'ToolEqu.a'
- INCLUDE 'Traps.a'
- PRINT ON
-
- Debug EQU 1 ; Set to 1 for debugging code, 0 for none
-
- MACRO
- &Label NewProc &PType=ENTRY,&Size=0,&Bug='None'
- &Label PROC &PType
- GBLA &ProcDB
- GBLC &ProcName
- &ProcDB SETA 0
- IF Debug>0|&UPCASE(&Bug)='DEBUG' THEN
- &ProcDB SETA 2
- &ProcName SETC &CONCAT(&UPCASE(&Label),' ')
- ELSEIF &Size<>0 THEN
- &ProcDB SETA 1
- ENDIF
- IF &ProcDB<>0 THEN
- LCLA &Sz
- &Sz SETA 0-&ABS(&Size)
- LINK A6,#&Sz
- ENDIF
- ENDM
-
- MACRO
- ProcExit &Size=0
- GBLA &ProcDB
- GBLC &ProcName
- IF &ProcDB>0 THEN
- UNLK A6
- ENDIF
- IF &Size<>0 THEN
- LCLA &Sz
- &Sz SETA &ABS(&Size)
- MOVE.L (SP),&Sz(SP)
- ADD.L #&Sz,SP
- ENDIF
- RTS
- IF &ProcDB=2 THEN
- LCLC &StrSet
- &StrSet SETC &SETTING('STRING')
- STRING ASIS
- DC.B '&ProcName[1:8]'
- STRING &StrSet
- ENDIF
- ENDM
-
- MACRO
- XIT &Where
- GBLA &ProcDB
- IF &ProcDB>0 THEN
- BRA.S &Where
- ELSE
- RTS
- ENDIF
- ENDM
-
-
-
- ScanOneDeskTop NewProc
- ;----------------------------------------------------------------
- ;
- ; Scan the desktop file of the specified volume looking for an
- ; application creator. If the volume is offline, return false
- ; immediately.
- ;
- ;
- ; On entry:
- ; D3 = creator to locate
- ; A2 = pointer to volume VCB
- ; A3 = address of area for short filename
- ;
- ; On exit:
- ; D0 = 0 if not found, non-zero if found
- ; D1 = directory in which found or zero
-
- DTApplRec RECORD 0,INCR
- dtCreator DS.L 1
- dtDir DS.L 1
- dtFilName DS.B 66
- ENDR
-
- WITH DTApplRec
-
- MOVEM.L D4/A2-A4,-(SP) ; Save registers
-
- CMP #TSigWord,vcbSigWord(A2) ; Is this an HFS volume?
- BNE @9 ; No, no point in continuing
-
- TST vcbDrvNum(A2) ; Is the volume off-line?
- BEQ @9 ; Branch to exit if so
-
- CLR -(SP) ; Disable SetResLoad to
- _SetResLoad ; prevent un-necessary preloads
-
- CLR -(SP) ; Open the desktop file
- PEA #'DeskTop'
- MOVE vcbVRefNum(A2),-(SP)
- MOVE.B #fsRdPerm,-(SP)
- _OpenRFPerm
-
- MOVE (SP)+,D4 ; Save the returned value
-
- MOVE #-1,-(SP) ; Enable SetResLoad
- _SetResLoad
-
- CMP #-1,D4 ; Was there an open error?
- BNE.S @1 ; Branch onwards if no error
-
- MOVEQ #0,D0 ; Return false
- MOVEQ #0,D1
- BRA.S @9 ; and exit
-
- @1 CLR.L -(SP) ; Get list of APPLs on volume
- MOVE.L #'APPL',-(SP)
- CLR -(SP)
- _GetResource
-
- MOVE.L (SP)+,D0 ; Get returned handle to data
- BEQ.S @8 ; Exit if NIL
-
- MOVE.L D0,A2 ; Save starting point of search
- MOVE.L (A2),A2
-
- CLR.L -(SP) ; Get size of APPL data
- MOVE.L D0,-(SP)
- _SizeRsrc
-
- MOVE.L A2,A4 ; Create ending point of search
- ADD.L (SP)+,A4
-
- @2 CMP.L #'APPL',D3 ; Searching for filename?
- BNE.S @3 ; Branch if not
-
- MOVEQ #0,D0 ; Compare filenames
- MOVE.L A3,A0
- MOVE.B (A0)+,D0
- SWAP D0
- LEA dtFilName(A2),A1
- MOVE.B (A1)+,D0
- _CmpString
-
- BNE.S @4 ; If not equal, get next entry
-
- MOVE.L dtDir(A2),D1 ; Get directory in which found
- MOVEQ #1,D0 ; Mark as found
- BRA.S @8
-
- @3 CMP.L dtCreator(A2),D3 ; Compare creators
- BNE.S @4 ; If not equal, get next entry
-
- LEA dtFilName(A2),A0 ; Copy filename
- MOVE.L A3,A1
- MOVEQ #1,D0
- ADD.B (A0),D0
- _BlockMove
-
- MOVE.L dtDir(A2),D1 ; Get directory in which found
- MOVEQ #1,D0 ; Mark as found
- BRA.S @8
-
- @4 MOVEQ #10,D0 ; Move to next entry
- ADD.B dtFilName(A2),D0
- BCLR #0,D0
- ADD D0,A2
-
- CMP A2,A4 ; At end of APPL list?
- BLO.S @2 ; Yes, branch back to test next one
-
- MOVEQ #0,D0 ; Clear result fields
- MOVEQ #0,D1
-
- @8 MOVEM.L D0-D1,-(SP) ; Save results
-
- MOVE D4,-(SP) ; Close the desktop file
- _CloseResFile
-
- MOVEM.L (SP)+,D0-D1 ; Restore results
-
- @9 TST D0 ; Set success/fail flag
- MOVEM.L (SP)+,D4/A2-A4 ; Restore registers
- ProcExit
-
-
-
- ScanDeskTop NewProc EXPORT,2
- ;----------------------------------------------------------------
- ;
- ; FUNCTION ScanDeskTop(creator: ResType; VAR appVol: INTEGER;
- ; VAR appDir: LongInt; VAR appName: Str255): BOOLEAN; EXTERNAL;
- ;
- ; Scan the desktop file of every on-line volume starting with
- ; the default volume, then in VCB order.
-
- StkFrame RECORD {A6Link},DECR
- Result DS.W 1
- Creator DS.L 1
- appVolPtr DS.L 1
- appDirPtr DS.L 1
- appNamPtr DS.L 1
- Return DS.L 1
- A6Link DS.L 1
- DefVol DS.W 1
- ENDR
-
- WITH StkFrame
-
- MOVEM.L D0-D7/A0-A4,-(SP) ; Save the registers
- CLR Result(A6) ; Set result false
-
- MOVE.L Creator(A6),D3 ; Search default volume
- MOVE.L DefVCBPtr,A2
- MOVE.L appNamPtr(A6),A3
- JSR ScanOneDeskTop
- BNE.S @3 ; If found, just to exit routine
-
- MOVE.L DefVCBPtr,D4 ; Get default (already searched)
- MOVE.L VCBQHdr+2,D0 ; Search volumes in turn
- BRA.S @2
-
- @1 MOVE.L (A2),D0 ; Get next VCB pointer
- BEQ.S @4 ; Exit if end of list
-
- @2 MOVE.L D0,A2 ; Move it to somewhere useful
- CMP.L D0,D4 ; Is it the default volume?
- BEQ.S @1 ; Ignore if so, already searched
-
- JSR ScanOneDeskTop ; Search this volume
- BEQ.S @1 ; If not found, search next volume
-
- @3 MOVE.L appVolPtr(A6),A0 ; Store vRefNum
- MOVE vcbVRefNum(A2),(A0)
-
- MOVE.L appDirPtr(A6),A0 ; Store directory number
- MOVE.L D1,(A0)
-
- MOVE #$0100,Result(A6) ; Set function true
-
- @4 MOVEM.L (SP)+,D0-D7/A0-A4 ; Restore the registers
- ProcExit 16
-
-
-
- END
-